import { Rule, RuleType } from "@midwayjs/decorator";
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE } from "../constants";

export class BaseDto {
  @Rule(RuleType.string().optional().allow(''))
  uid?: string;
}

@Rule(BaseDto)
export class PagingDto extends BaseDto {
  @Rule(RuleType.number().optional().allow('').min(1).default(DEFAULT_PAGE_INDEX))
  pi: number = DEFAULT_PAGE_INDEX;

  @Rule(RuleType.number().optional().allow('').max(MAX_PAGE_SIZE).min(1).default(DEFAULT_PAGE_SIZE))
  ps: number = DEFAULT_PAGE_SIZE;

  @Rule(RuleType.number().optional().allow('').default(0))
  sp: number = 0;

  @Rule(RuleType.number().optional().allow('').default(1))
  paging: number = 1;
}